//
//  PageControlDemo.m
//  Exercise
//
//  Created by zhouxiaobo on 15/11/12.
//  Copyright © 2015年 mapath. All rights reserved.
//

#import "PageControlDemo.h"

@implementation PageControlDemo

- (void)viewDidLoad {
    [super viewDidLoad];
    UIPageControl *pageControl = [[UIPageControl alloc]init];
    pageControl.frame = CGRectMake(screenWidth/2-100, 100, 200, 50);
    pageControl.numberOfPages = 5;
    pageControl.currentPage =2;
    pageControl.backgroundColor = [UIColor grayColor];
    
    //设置不可点击
    //pageControl.enabled = NO;
    
    [pageControl addTarget:self action:@selector(change:) forControlEvents:UIControlEventValueChanged];
    
    [self.view addSubview:pageControl];
    
}

- (void)change:(id)sender{
    UIPageControl *control = (UIPageControl *)sender;
    NSLog(@"点击了%d",control.currentPage);
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
}

@end
